﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using StructureMap;
using StructureMap.Configuration;
using StructureMap.Configuration.DSL;

using ContactManager;
using ContactManager.Models;
using ContactManager.Models.Entities;
using ContactManager.Models.Repositories;
using ContactManager.Models.Validation;

namespace ContactManager.Models

{

    public class RepositoryRegistry : Registry
    {
        
          
       

        public RepositoryRegistry()
        {
            For<IValidator<Contact>>().Use<ContactValidator>();
            
            For<IValidator<ContactGroup>>().Use<ContactGroupValidator>();
            //For<IModelStateWrapper>().Use<ModelStateWrapper>();
            For<IContactManagerService>().Use<ContactManagerService>();
            For<IContactManagerRepositoryAr>().Use<ContactManagerRepositoryAr>();
            For<IValidationService>() .Use<ValidationService>();
            For<IGroupManagerRepository>().Use<GroupManagerRepository>();
            
            
            //Scan(assemblyScanner =>
            //{
            //    assemblyScanner.TheCallingAssembly();
            //    assemblyScanner.WithDefaultConventions();
            //});

            

            // Now, I'll add three more Instances of IRepository

            //ForRequestedType<IRepository>().AddInstances(x =>
            //{

                // "NorthAmerica" is the concrete type DatabaseRepository with 

                // the connectionString pointed to the NorthAmerica database

              //  x.OfConcreteType<DatabaseRepository>().WithName("NorthAmerica")

                //    .WithCtorArg("connectionString").EqualTo("database=NorthAmerica");



                // "Asia/Pacific" is the concrete type DatabaseRepository with 

                // the connectionString pointed to the AsiaPacific database

                //x.OfConcreteType<DatabaseRepository>().WithName("Asia/Pacific")

                  //  .WithCtorArg("connectionString").EqualTo("database=AsiaPacific");



                // Lastly, the "Weird" instance is built by calling a specified 

                // Lambda (an anonymous delegate will work as well).

               // x.ConstructedBy(() => WeirdLegacyRepository.Current).WithName("Weird");

            //});

        }

    }


   
}
